<template>
	<view class="content" :style="{background:'#F7F7F7;'}">
		<block v-for="(item, index) in problemlist" :key="index">
			<view class="public-question-box" :style="{background:'#FFFFFF'}">
				<view class="question-title" @click="changeAnswer(index)">
					<view class="left-q">
						<image class="q-icon" src="../../../static/question.png" mode=""></image>
						<text class="font34" :style="{color:'#111111;'}">{{item.name}}</text>
					</view>
					<image class="show-more-icon" :class="item.state?'show-open':'show-close'" src="../../../static/showmoer.png" mode=""></image>
				</view>
				<view class="answer-text" v-if="item.state">
					<image class="answer-icon" src="../../../static/answer.png" mode=""></image>
					<rich-text class="font28 answer-info" :style="{color:'#AEAEAE;'}" :nodes="item.content"></rich-text>
				</view>
			</view>
		</block>
	</view>
</template>

<script>
	var util = require('@/js/util.js')
	export default {
		data() {
			return {
				show_answer:false,
				problemlist:[]
			}
		},
		onShow() {
			this.getProblemData()
		},
		methods: {
			getProblemData(){
				let _self = this
				uni.request({
					url: util.getUrl("member/qa"),
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authori-zation':uni.getStorageSync("token")
					},
					data:{
					},
					method: 'POST',
					success: res => {
						if(res.data.code == 1){
							_self.problemlist = res.data.data.list
						}
					},
				});
			},
			changeAnswer(index){
				this.problemlist[index].state = !this.problemlist[index].state
			},
		}
	}
</script>

<style lang="scss" scoped>
	.answer-text{
		display: flex;
		width: 100%;
		margin-top: 51upx;
		.answer-icon{
			width: 30upx;
			height: 30upx;
			margin-right: 22upx;
		}
		.answer-info{
			line-height: 40upx;
		}
	}
	.question-title{
		display: flex;
		align-items: center;
		width: 100%;
		justify-content: space-between;
		.left-q{
			display: flex;
			align-items: center;
			.q-icon{
				width: 30upx;
				height: 30upx;
				margin-right: 20upx;
			}
		}
		.show-open{
			transform: rotate(180deg);
		}
		.show-close{
			transform: rotate(0deg);
		}
		.show-more-icon{
			width: 31upx;
			height: 20upx;
		}
	}
	.public-question-box{
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 690upx;
		padding: 32upx;
		border-radius: 20upx;
		overflow: hidden;
		margin-bottom: 30upx;
	}
	.content{
		width: 750upx;
		display: flex;
		align-items: center;
		flex-direction: column;
		min-height: 100vh;
		padding: 30upx;
		box-sizing: border-box;
	}
</style>
